<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\StringHelper;
use backend\helpers\ActionButton;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\EventPriceSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Цена билетов';
$this->params['breadcrumbs'][] = ['label' => 'События', 'url' => ['event/index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="container event-price-index">

    <h1 class="main-title"><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= ActionButton::create('Создать группу цен', 'createEventPrice') ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'tableOptions' => [
            'class' => 'table table-striped'
        ],
        'columns' => [
            'id',
            'title',
            [
                'attribute' => 'content',
                'contentOptions' => ['style' => 'width:480px; white-space: normal;'],
                'value' => function($model, $key, $index, $column) {
                    return StringHelper::truncate($model->content, 50);
                },
                'format' => 'ntext',
            ],
            [
                'class' => 'yii\grid\ActionColumn',
                'visibleButtons' =>
                [
                    'view' => Yii::$app->user->can('browseEventPrice'),
                    'update' => Yii::$app->user->can('updateEventPrice'),
                    'delete' => Yii::$app->user->can('deleteEventPrice'),
                ]
            ],
        ],
    ]); ?>
</div>
